(function (vc) {
  vc.extends({
    data: {
      writeOweFeeCallableInfo: {
        roomId: "",
        roomName: "",
        fees: [],
        feeIds: [],
        remark: "",
        areaManage: "",
        nature: "",
        shopName: "",
        shopType: "",
        changeType: "",
        costMain: "",
        causea: "",
        causeb: "",
        recycle: "",
        dutyDept: "",
        measure: "",
        milestone:'',
      },
    },
    _initMethod: function () {},
    _initEvent: function () {
      vc.on(
        "writeOweFeeCallable",
        "openWriteOweFeeCallableModal",
        function (_param) {
          debugger;
          vc.copyObject(_param._callables, $that.writeOweFeeCallableInfo);
          $that.writeOweFeeCallableInfo.measure="";
          $that.writeOweFeeCallableInfo.milestone = ""; 
          $that.writeOweFeeCallableInfo.remark="";
          $that._loadWriteOweRoomFees();
          $("#writeOweFeeCallableModel").modal("show");
        }
      );
    },
    methods: {
        writeOweFeeCallableValidate() {
        return vc.validate.validate(
          {
            writeOweFeeCallableInfo: vc.component.writeOweFeeCallableInfo,
          },
          {
            "writeOweFeeCallableInfo.projectName": [
              {
                limit: "areaManage",
                param: "",
                errInfo: "区域管家不能为空",
              },
            ],
            "writeOweFeeCallableInfo.shopName": [
              {
                limit: "required",
                param: "",
                errInfo: "店铺名称不能为空",
              },
            ],
            "writeOweFeeCallableInfo.nature": [
              {
                limit: "required",
                param: "",
                errInfo: "使用性质不能为空",
              },
            ],

            "writeOweFeeCallableInfo.shopType": [
              {
                limit: "required",
                param: "",
                errInfo: "商铺经营类型不能为空",
              },
            ],
            "writeOweFeeCallableInfo.changeType": [
              {
                limit: "required",
                param: "",
                errInfo: "住改商类型不能为空",
              },
            ],
            "writeOweFeeCallableInfo.costMain": [
              {
                limit: "required",
                param: "",
                errInfo: "交费主体不能为空",
              },
            ],
            "writeOweFeeCallableInfo.causea": [
              {
                limit: "required",
                param: "",
                errInfo: "欠费原因大类不能为空",
              },
            ],
            "writeOweFeeCallableInfo.causeb": [
              {
                limit: "required",
                param: "",
                errInfo: "欠费原因小类不能为空",
              },
            ],
            "writeOweFeeCallableInfo.recycle": [
              {
                limit: "required",
                param: "",
                errInfo: "回收方式不能为空",
              },
            ],
            "writeOweFeeCallableInfo.dutyDept": [
              {
                limit: "required",
                param: "",
                errInfo: "责任部门不能为空",
              },
            ],
            "writeOweFeeCallableInfo.remark": [
              {
                limit: "required",
                param: "",
                errInfo: "催缴详情不能为空",
              },
            ],
            "writeOweFeeCallableInfo.measure": [
              {
                limit: "required",
                param: "",
                errInfo: "解决的措施不能为空",
              },
            ],
            "writeOweFeeCallableInfo.milestone": [
              {
                limit: "required",
                param: "",
                errInfo: "里程碑不能为空",
              },
            ],
          }
        );
      },

      _wirteCallable: function () {
        if (!vc.component.writeOweFeeCallableValidate()) {
          vc.toast(vc.validate.errInfo);

          return;
        }

        $that.writeOweFeeCallableInfo.communityId =
          vc.getCurrentCommunity().communityId;
        vc.http.apiPost(
          "/oweFeeCallable.writeOweFeeCallable",
          JSON.stringify($that.writeOweFeeCallableInfo),
          {
            emulateJSON: true,
          },
          function (json, res) {
            let _json = JSON.parse(json);
            if (_json.code == 0) {
              //关闭model
              $("#writeOweFeeCallableModel").modal("hide");
              $that.clearWriteOweFeeCallable();
              vc.emit("oweFeeCallable", "listOweFeeCallable", {});
              vc.emit("simplifyCallable", "listOwnerData", {});

              vc.toast("登记成功");
              return;
            } else {
              vc.toast(_json.msg);
            }
          },
          function (errInfo, error) {
            console.log("请求失败处理");
            vc.message(errInfo);
          }
        );
      },
      clearWriteOweFeeCallable: function () {
        $that.writeOweFeeCallableInfo = {
          roomId: "",
          roomName: "",
          fees: [],
          feeIds: [],
          remark: "",
          areaManage: "",
            nature: "",
            shopName: "",
            shopType: "",
            changeType: "",
            costMain: "",
            causea: "",
            causeb: "",
            recycle: "",
            dutyDept: "",
            measure: "",
            milestone:'',
        };
      },

      _loadWriteOweRoomFees: function () {
        let param = {
          params: {
            page: 1,
            row: 100,
            communityId: vc.getCurrentCommunity().communityId,
            payerObjId: $that.writeOweFeeCallableInfo.roomId,
            state: "2008001",
          },
        };
        //发送get请求
        vc.http.apiGet(
          "/fee.listFee",
          param,
          function (json) {
            let _json = JSON.parse(json);
            $that.writeOweFeeCallableInfo.fees = _json.fees;
          },
          function () {
            console.log("请求失败处理");
          }
        );
      },
    },
  });
})(window.vc);
